public class test07 {
    public boolean repeatedSubstringPattern(String s) {
        int len = s.length();
        s = " "+s;
        char[] array = s.toCharArray();
        int j = 0;
        int[] next = new int[len+1];
        for(int i = 2;i<=len;i++){
            while(j>0 && array[i]!=array[j+1]){
                j = next[j];
            }
            if(array[i]==array[j+1]){
                j++;
            }
            next[i] = j;
        }

        if(next[len]>0 && len%(len-next[len])==0){
            return true;
        }
        return false;
    }
}
